package com.example.baiduapi.Chart.Picther;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class TestDX {
    public static void main(String[] args) {
        ExecutorService excutor = Executors.newFixedThreadPool(5);
        for (int i = 0; i < 10; i++) {
            Runnable worker = new WorkerThread("" + i);
            excutor.execute(worker);
        }
    }
    static class WorkerThread implements Runnable {
        private String command;

        WorkerThread(String s) {
            this.command = s;
        }

        @Override
        public void run() {
            System.out.println(Thread.currentThread().getName() + " 开始. 命令 = " + command);
            processCommand();
            System.out.println(Thread.currentThread().getName() + " 结束.");
        }

        private void processCommand() {
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        @Override
        public String toString() {
            return this.command;
        }
    }
}
